/*
** baguette.c for  in /home/lucas/projet/philosophe/laidfilauxzauphe
** 
** Made by Lucas Stefas
** Login   <stefas_l@epitech.net>
** 
** Started on  Sat Apr 30 10:05:19 2011 Lucas Stefas
** Last update Sat Apr 30 10:05:23 2011 Lucas Stefas
*/

#include <unistd.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <pthread.h>
#include "plsp.h"

int		be_used(baguette* self)
{
  pthread_mutex_lock(&self->mutex);
  if (self->is_used)
    {
      pthread_mutex_unlock(&self->mutex);
      return (0);
    }
  self->is_used = 1;
  pthread_mutex_unlock(&self->mutex);
  return (1);
}

void		free_baguette(baguette *self)
{
  pthread_mutex_lock(&self->mutex);
  self->is_used = 0;
  pthread_mutex_unlock(&self->mutex);
}
